/*
 *  Copright: 2008 Philipp Leitner, Distributed Systems Group,
 *            TU Wien, leitner@infosys.tuwien.ac.at
 *
 *  This file is part of DAIOS.
 *
 *  DAIOS is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as
 *  published by the Free Software Foundation.
 * 
 *  DAIOS is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with DAIOS.  If not, see
 *  <http://www.gnu.org/licenses/>.
 * 
 */

package at.ac.tuwien.infosys.dsg.daios.framework;

import java.net.URL;

import javax.wsdl.Definition;

import at.ac.tuwien.infosys.dsg.daios.framework.interfaces.IServiceFrontendImplementor;
import at.ac.tuwien.infosys.dsg.daios.framework.structs.DaiosInputMessage;
import at.ac.tuwien.infosys.dsg.daios.framework.structs.DaiosOutputMessage;
import at.ac.tuwien.infosys.dsg.daios.wsdl.WSDLEncoding;
import at.ac.tuwien.infosys.dsg.daios.wsdl.interfaces.IWSDL;
import at.ac.tuwien.infosys.dsg.daios.wsdl.interfaces.IWSDLMessage;
import at.ac.tuwien.infosys.dsg.daios.wsdl.interfaces.IWSDLOperation;
import at.ac.tuwien.infosys.dsg.daios.wsdl.typesystem.WSDLTypeTree;

/**
 * This is the default interceptor for Daios invocations.
 * The interceptor receives all events, but does not do anything
 * by default.
 * 
 * @author philipp
 *
 */
public class DefaultInterceptor extends DaiosInterceptor {

	/**
	 * Notifies that the creation process of a new frontend
	 * has been started.
	 * 
	 * @param fac The factory that is used to create the
	 * frontend.
	 * @param location The URL location that this frontend
	 * will point to.
	 */
	public void beginFrontendCreation(ServiceFrontendFactory fac,
			URL location){}
	
	/**
	 * Notifies that WSDL4J has started processing a WSDL
	 * description.
	 * 
	 * @param url The location of the WSDL description to
	 * parse.
	 */	
	public void beginWSDLProcessing(URL url){}
	
	/**
	 * Notifies that WSDL4J has finished processing a WSDL
	 * description, and the description is now available
	 * in Daios notation.
	 * 
	 * @param url The location of the WSDL description to
	 * parse.
	 * @param wsdl The newly created WSDL wrapper object.
	 */		
	public void finishedWSDLProcessing(URL url,
			IWSDL wsdl){}
	
	/**
	 * Notifies that Daios started reading an example
	 * from an URL.
	 * 
	 * @param url The URL of the example.
	 * @param invoker
	 */
	public void beginRESTExampleFetching(URL url,
			IServiceFrontendImplementor invoker){}

	/**
	 * Notifies that Daios finished reading an example
	 * from an URL.
	 * 
	 * @param url The URL of the example.
	 * @param invoker
	 * @param example The read example file.
	 */	
	public void finishedRESTExampleFetching(URL url,
			IServiceFrontendImplementor invoker, String example){}
	
	/**
	 * Notifies that XMLBeans started compiling the XML schema
	 * contained in a WSDL definition.
	 * 
	 * @param style The encoding style used (e.g rpc/encoded)
	 * @param wsdl The WSDL definition file.
	 * @param location The location of the original definition.
	 */
	public void beginWSDLTypeParsing(WSDLEncoding style, Definition wsdl,
			URL location){}
	
	/**
	 * Notifies that XMLBeans finished compiling the XML schema
	 * contained in a WSDL definition.
	 *  
	 * @param style The encoding style used (e.g rpc/encoded)
	 * @param wsdl The WSDL definition file.
	 * @param location The location of the original definition.
	 * @param types The type system that has been generated from
	 * the WSDL definitions.
	 */
	public void finishedWSDLTypeParsing(WSDLEncoding style, Definition wsdl,
			URL location, WSDLTypeTree types){}
	
	/**
	 * Notifies that the creation process of a new frontend
	 * has been finished and the new frontend is ready for
	 * invocation.
	 * 
	 * @param fac The factory that has been used to create the
	 * frontend.
	 * @param location The URL location that this frontend
	 * points to.
	 * @param frontend The newly generated frontend.
	 */
	public void finishedFrontendCreation(ServiceFrontendFactory fac,
			URL location, ServiceFrontend frontend){}
	
	/**
	 * Notifies that a service frontend has started with an invocation.
	 * 
	 * @param style The service style (SOAP or REST)
	 * @param invocationType The type of the invocation (e.g
	 * request/response or pollobject).
	 * @param message The input message for this invocation.
	 * @param invoker The service invoker that is responsible
	 * for this invocation.
	 */
	public void beginInvocation(String style, String invocationType,
			DaiosInputMessage message, IServiceFrontendImplementor invoker){}
	
	/**
	 * Notifies that a service frontend has started converting an
	 * input message to AXIOM.
	 * 
	 * @param message
	 * @param operation
	 * @param wsdlMsg
	 * @param wsdl
	 * @param invoker
	 */
	public void beginInputConversion(DaiosInputMessage message, 
			IWSDLOperation operation, IWSDLMessage wsdlMsg, IWSDL wsdl,
			IServiceFrontendImplementor invoker){}

	/**
	 * Notifies that a service frontend finished converting an
	 * input message to AXIOM.
	 * 
	 * @param message
	 * @param operation
	 * @param wsdlMsg
	 * @param wsdl
	 * @param invoker
	 * @param xmlBody
	 */
	public void finishedInputConversion(DaiosInputMessage message,
			IWSDLOperation operation, IWSDLMessage wsdlMsg, IWSDL wsdl,
			IServiceFrontendImplementor invoker, String xmlBody){}
	
	/**
	 * Notifies that Daios is about to start transferring a message
	 * over the wire.
	 * 
	 * @param endpoint
	 * @param body
	 * @param invoker
	 */
	public void doHTTPInvocation(String endpoint, String body,
			IServiceFrontendImplementor invoker){}

	/**
	 * Notifies that Daios finished the actual invocation and received
	 * a response from the server.
	 * 
	 * @param endpoint
	 * @param body
	 * @param invoker
	 * @param response
	 */
	public void receiveHTTPResult(String endpoint, String body,
			IServiceFrontendImplementor invoker, String response){}
	
	/**
	 * Notifies that a Service Frontend has started to convert a SOAP response
	 * into a Daios message.
	 * 
	 * @param message
	 * @param outputMsgToUse
	 * @param wsdl
	 * @param invoker
	 * @param element
	 */
	public void beginOutputConversion(DaiosInputMessage message,
			IWSDLMessage outputMsgToUse, IWSDL wsdl, IServiceFrontendImplementor invoker,
			String element){}
	
	/**
	 * Notifies that a Service Frontend finished to convert a SOAP response
	 * into a Daios message.
	 * 
	 * @param message
	 * @param outputMsgToUse
	 * @param wsdl
	 * @param invoker
	 * @param element
	 */
	public void finishedOutputConversion(DaiosInputMessage message,
			IWSDLMessage outputMsgToUse, IWSDL wsdl, IServiceFrontendImplementor invoker,
			String element, DaiosOutputMessage output){}	
	
	/**
	 * Notifies that a service frontend has successfully
	 * finished an invocation.
	 * 
	 * @param style The service style (SOAP or REST)
	 * @param invocationType The type of the invocation (e.g
	 * request/response or pollobject).
	 * @param message The input message for this invocation.
	 * @param invoker The service invoker that is responsible
	 * for this invocation.
	 * @param output The result message of the invocation.
	 */
	public void finishedInvocation(String style, String invocationType,
			DaiosInputMessage message, IServiceFrontendImplementor invoker,
			DaiosOutputMessage output){}

}
